package services;

import dao.StudentUserDao;
import model.Student;
import model.User;

import java.util.List;

public class UserServiceForStudentManagement {
    public static boolean isExistUser(String username)
    {
        StudentUserDao sud=new StudentUserDao();
        List<User> list= sud.findUserByName(username);
        if(list!=null)
            return true;
        else
            return false;
    }

    public static boolean login(String username,String password)
    {
        StudentUserDao sud=new StudentUserDao();
        List<User> list= sud.findUSerByNameandByPwd(username, password);
        if(list!=null)
            return true;
        else
            return false;
    }
    public static boolean register(User user)
    {
        StudentUserDao sud=new StudentUserDao();
        int result= sud.insert_user(user.getUsername(),user.getPassword(),user.getLevel());
        if(result!=0)
            return true;
        else
            return false;
    }
}
